#include <stdio.h>
#include <pthread.h>

int a;

void* sum(void* arg)
{
	int i = 0;
	for (; i < 10000000; i++)
	{
		a++;
	}
	return NULL;
}

void test(void)
{
	a = 0;
	pthread_t t1, t2;
	pthread_create(&t1, NULL, sum, NULL);
	pthread_create(&t2, NULL, sum, NULL);

	pthread_join(t1, NULL);
	pthread_join(t2, NULL);

	printf("a = %d\n", a);
}

int main(void)
{
	test();
	test();
	test();
	return 0;
}
